#ifndef __SCC_SCCILP_H
#define __SCC_SCCILP_H

#include <scos.h>
#include "scc.h"
#include "timer.h"

#ifdef PSOS
#define SCCILP_SEQUENCE_INPUT "/flash/seq*"
#define SCCILP_IMAGE_INPUT  "/flash/in%d.raw"
#define SCCILP_IMAGE_OUTPUT "/flash/out%d.raw"
#else
#define SCCILP_SEQUENCE_INPUT "/data/scratch/wcaarls/seq*"
#define SCCILP_IMAGE_INPUT  "/data/scratch/wcaarls/in%d.raw"
#define SCCILP_IMAGE_OUTPUT "/data/scratch/wcaarls/out%d.raw"
#endif

#ifdef PSOS
#define scuBufferGetStride(x) 640
#define scuBufferGetLines(x)  480
#else
#define scuBufferGetStride(x) 1024
#define scuBufferGetLines(x)  1024
#endif

typedef struct ilp_arg_s
{
  short int id;
  unsigned short int type;
  union
  {
    unsigned char b[8];    /* Must be 4-byte aligned for TriMedia! */
    int d;
    double f;
  } data;
  unsigned short int intent;
  scu_buf_t *buffer;
  scu_bufptrid_t reader;
  unsigned char *buf;
} ilp_arg_t;

typedef struct ilp_op_s
{
  short int id;
  unsigned short int operation;
  ilp_arg_t argument[SC_MAX_ARGUMENTS];
  unsigned short int arguments, argreceived;
  tmr_t timer;
} ilp_op_t;

void scIlpInit(int proc);
void ilpProcessMessage(scc_hdr_t *hdr);
void *ilpOperationEnqueue(void *op);
ilp_op_t *ilpOperationAllocate(void);
ilp_op_t *ilpOperationFind(int id);
void ilpOperationFree(ilp_op_t *op);
void ilpWriteResult(ilp_op_t *o, int id, int type, char *data);
void ilpOperationComplete(ilp_op_t *o);
void ilpBufferDestructor(scu_buf_t *buf);
void ilpTransportReceiver(scc_hdr_t *hdr);
unsigned long int ilpBufferQuery(int buffer);

void ilpCustomOperationEnqueue(ilp_op_t *op);

#endif /* __SCC_SCCILP_H */
